#include <stdio.h>
#include <stdlib.h>
#include "studentInfo.h"
#include "login.h"
int startRun()
{
    printf("学生信息管理系统\n");
    printf("请选择功能\n");
    printf("1.增加学生信息\n");
    printf("2.删除学生信息\n");
    printf("3.修改学生信息\n");
    printf("4.查看特定学生信息\n");
    printf("5.查看所有学生信息\n");
    printf("6.切换用户\n");
    printf("0.退出系统\n");
    int num;
    scanf("%d", &num);
    return num;
}
int loginInterface()
{
    printf("登录学生信息管理系统\n");
    printf("请选择功能\n");
    printf("1.登录\n");
    printf("2.注册\n");
    printf("0.退出系统\n");
    int num;
    scanf("%d", &num);
    return num;
}
void loginRun()
{
    while (1)
    {
        int num = loginInterface();
        int ret = 1;
        switch (num)
        {
        case 1:
            ret = signIn();
            break;
        case 2:
            regUser();
            break;
        case 0:
            printf("退出系统成功\n");
            exit(0);
        default:
            printf("无此功能，请重新选择！\n");
            break;
        }
        if (ret == 0)
            break;
    }
}
void main()
{
    logReadFromFile();
    loginRun();
    readFromFile();
    while (1)
    {
        int num = startRun();
        switch (num)
        {
        case 1:
            addStudentInfo();
            break;
        case 2:
            delStudentInfo();
            break;
        case 3:
            updateStudentInfo();
            break;
        case 4:
            PrintfStuFromNo();
            break;
        case 5:
            printfAllStu();
            break;
        case 6:
            loginRun();
            break;
        case 0:
            printf("退出系统成功\n");
            exit(0);
        default:
            printf("无此功能，请重新选择！\n");
            break;
        }
    }
}